package name.panitz.mobile;
import javax.microedition.lcdui.*;
import java.util.*;
public class SimpleMidlet extends GameMidlet {
  MovableObject moveMe;
  
  public SimpleMidlet() {
    myCanvas=new MyCanvas(){
      protected void keyPressed(int keyCode){
        if (keyCode==Canvas.KEY_NUM4) moveMe.x-=1;
        if (keyCode==Canvas.KEY_NUM6) moveMe.x+=1;
        if (keyCode==Canvas.KEY_NUM2) moveMe.y-=1;
        if (keyCode==Canvas.KEY_NUM8) moveMe.y+=1;
      } 
    };
    initDisplay();

    moveMe=new MovableObject(100,100,0,0,10,10);
    mos.addElement(moveMe);
    mos.addElement(new MovableObject(100,1,0,1,10,10));
  }

  public void doOnTic(){
    super.doOnTic();
    for (Enumeration e = mos.elements();e.hasMoreElements();){
      MovableObject mo=(MovableObject)e.nextElement();	
      if (mo.y>myCanvas.getHeight()) mo.y=0;
      if (mo.y<0) mo.y=myCanvas.getHeight();
      if (mo.x>myCanvas.getWidth()) mo.x=0;
      if (mo.x<0) mo.x=myCanvas.getWidth();
    }
  }
}

